Problem with multi-valored attribute

I have created a dxl GUI, and in that GUI, the user can choose in a multilist, one or two options that are update in a attribute inside the module.
The problem is that when the object attribute is empty, and in the GUI its is empty too, when a choose to go to the next requirement, the GUI update the module attribute value without the necessity of choosing.
I really dont get what is happening.

This is my update code

void updateVariables() {
    string currentQA = obj."Applicability" ""
        string currentQE = obj."Validation Ensure" ""
 
        for iQE in 0:2 by 1 do {
                if (currentQE == answerType2.strings[iQE]) { break }
                iQE++
        }
        
 
        set(selectChoiceQA, -1)
        attrAppliType = find(current Module, "Applicability")
        for(attrAppliIndex=0; attrAppliIndex<attrAppliType.size; attrAppliIndex=attrAppliIndex+1) {
                if(isMember(obj."Applicability", attrAppliType.strings[attrAppliIndex])) {
                                set(selectChoiceQA, attrAppliIndex)
                        } 
                }
         
        set(tagField, identifier(obj))
        set(selectChoiceQE,iQE)
        if(null obj."Object Text" "") set(richTextReq, "<Title>")  // Avoid headings.
        else set(richTextReq, obj."Object Text" "")
        refresh current Module
}

 


and this my choice code

 

 

void saveObjects(){
    string aux = ""
        int i
        bool wasModified = false
        
    if(canModify(obj)){
        
            
                        aux = get(selectChoiceQE)
                        if(obj."Validation Ensure" "" != aux) {
                                obj."Validation Ensure" = aux
                                wasModified = true
                        }    
                        
                        aux = get(selectChoiceQA)
                        if(obj."Applicability" "" != aux) {
                                obj."Applicability" += aux
                                wasModified = true
                        }                                    
                
                        // Save checker
                        if(wasModified){     // Saves Checker just if something has changed.
                                User u = find() // returns current user login.          
                                string uName    = u.name
                                if(obj."Object Heading" "" == "") obj."Checker" = uName// just save if is requirement.
                        }
                }
        else infoBox "Cannot modify current object."
}

 


Bruwbruw - Mon Mar 12 13:25:34 EDT 2012

Re: Problem with multi-valored attribute
llandale - Tue Mar 13 13:29:17 EDT 2012

I don't see this completely, but this is what I see.

In updateVariables(), you are incrementing the loop counter inside the loop

In saveObjects() at the bottom, I think you can just do this without issueing a "find":
  • if(obj."Object Heading" "" == "") obj."Checker" = doorsName() // just save if is requirement

In saveObjects() you seem to be trying to add an enumerated selected value to a multi-enumerated attribute "Applicability" with the "aux" read from the dialog. I think though that "aux" is all the selected values, whereas the "+=" only works for actual single enerated values.
  • Change line 17 from to

You can do one of these:
  • obj."Applicability" = "P1\nP3" // set the value directly using "=" not "+="
or...
  • obj."Applicability" += "P1" // add each selection
  • obj."Applicability" += "P3"
  • obj."Applicability" -= "P2" // just in case its currently selected

-Louie

Re: Problem with multi-valored attribute
Bruwbruw - Fri Mar 16 08:06:31 EDT 2012

Thanks!!
I will keep that in mind, so maybe the next time i don't waste too much time trying to fix it.
A found another solution, i will let it here if someone else have a similar problem.
I did it to the:

void updateVariables() 
.
.
.
set(selectChoiceQA, -1)
    for(attrAppliIndex=0; attrAppliIndex<answerType3.size; attrAppliIndex=attrAppliIndex+1) {
                if(isMember(obj."Applicability", answerType3.strings[attrAppliIndex])) {
                                set(selectChoiceQA, attrAppliIndex)
                        } 
                }

and this to the:

 

void saveObjects()
.
.
.
for (attrAppliIndex=0; attrAppliIndex<noElems(selectChoiceQA); attrAppliIndex++) {
    aux = get(selectChoiceQA, attrAppliIndex)
           if (selected(selectChoiceQA, attrAppliIndex)) {
                obj."Applicability" += aux
                wasModified = true
                } else {
                obj."Applicability" -= aux
                wasModified = true
        }
}